package com.scoresystem.dao.proxy;

import java.sql.Connection;

import com.scoresystem.dao.ITeacherDao;
import com.scoresystem.dao.impl.TeacherDaoImpl;
import com.scoresystem.model.Student;
import com.scoresystem.model.Teacher;
import com.scoresystem.utils.JdbcUtil;

public class TeacherDaoProxy implements ITeacherDao {
	
	private ITeacherDao dao;
	private Connection conn;
	public TeacherDaoProxy()throws Exception{
		conn=JdbcUtil.getInstance().getConnection();
		dao=new TeacherDaoImpl(conn);
	}
	@Override
	public boolean add(Teacher teacher) {
		boolean bool=dao.add(teacher);
		JdbcUtil.getInstance().free(conn);
		return bool;
	}

	@Override
	public boolean modify(Teacher teacher) {
		boolean bool=dao.modify(teacher);
		JdbcUtil.getInstance().free(conn);
		return bool;
	}

	@Override
	public boolean deleteTeachers(String[] worknum) {
		boolean bool=dao.deleteTeachers(worknum);
		JdbcUtil.getInstance().free(conn);
		return bool;
	}

	@Override
	public Teacher findbyName(String teaname) {
		Teacher teacher=dao.findbyName(teaname);
		JdbcUtil.getInstance().free(conn);
		return teacher;
	}

	@Override
	public Teacher findbyNum(String worknum) {
		Teacher teacher=dao.findbyNum(worknum);
		JdbcUtil.getInstance().free(conn);
		return teacher;
	}

}
